#### Table S15: Multilevel regression (WaPo) ####

# Libraries
# library(here)
# library(rio)
# library(tidyverse)
# library(lubridate)
# library(stargazer)
# library(lme4)

# data_pnas = import(here("Data","data_pnas.rds"))

p_wapo_mod1 = lmer(norm_loyaltyre ~ denied_wapo + (1 | district) + (1 | uid), data = data_pnas, weights = weight)
p_wapo_mod2 = lmer(norm_loyaltyre ~ denied_wapo*pid + (1 | district) + (1 | uid), data = data_pnas, weights = weight)
p_wapo_mod3 = lmer(norm_loyaltyre ~ denied_wapo + (1 | district) + (1 | uid), 
                   data = data_pnas |> filter(date >= mdy("01/03/2023")), weights = weight)
p_wapo_mod4 = lmer(norm_loyaltyre ~ denied_wapo*pid + (1 | district) + (1 | uid),
                   data = data_pnas |> filter(date >= mdy("01/03/2023")), weights = weight)

stargazer(p_wapo_mod1, p_wapo_mod2, p_wapo_mod3, p_wapo_mod4,
          title = "Multilevel Regression Results - Washington Post",
          dep.var.labels = "Loyalty",
          column.labels = c("Full","Full","2023","2023"),
          covariate.labels = c("Election Denial (WaPo)",
                               "Independent",
                               "Republican",
                               "Election Denial (WaPo):Independent",
                               "Election Denial (WaPo):Republican"),
          notes = "Estimated with survey weights and two-sided tests",
          star.cutoffs = c(0.05, 0.01, 0.001),
          omit.stat = c("aic","bic"),
          type = "latex",
          out = here("Tables","Supplementary","table_s15.tex"),
          header = F)